package com.shijunhao.graduation.controller;

import com.shijunhao.graduation.domain.bean.ResultCode;
import com.shijunhao.graduation.domain.vo.UserAllCulVo;
import com.shijunhao.graduation.properties.RoleParams;
import com.shijunhao.graduation.service.business.IBusinessCulService;
import com.shijunhao.graduation.service.business.IBusinessUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: shijunhao
 * @date: 2022/5/29 19:54
 * @description:
 */
@RestController
@RequestMapping("/business-cul")
@Api(tags = "信息统计")
public class BusinessCulController {

    @Resource
    private IBusinessCulService businessCulService;
    @Resource
    private IBusinessUserInfoService userInfoService;

    @GetMapping("selfCul")
    @ApiOperation("个人统计查询")
    public ResultCode<UserAllCulVo> selfCul() {
        String role = userInfoService.getCurrentOrgUser().getRole();
        if(RoleParams.ADMIN.equals(role))
            return ResultCode.success(businessCulService.culAll());
        else
            return ResultCode.success(businessCulService.culSelf());
    }
}
